import logging


class Logger:
    def __init__(self, filename="logging.log", level="DEBUG"):
        self.logger = logging.getLogger(__name__)
        self.logger.setLevel(level)

        self.logger.addHandler(Logger.console_handler())
        self.logger.addHandler(Logger.file_handler(filename=filename))

    def get_logger(self):
        return self.logger

    @staticmethod
    def console_handler(level="INFO"):
        fmt = logging.Formatter(fmt="%(levelname)-10s  %(asctime)s :: %(message)s")
        console_handler = logging.StreamHandler()
        console_handler.setLevel(level)
        console_handler.setFormatter(fmt)
        return console_handler

    @staticmethod
    def file_handler(level="DEBUG", filename=None):
        if filename is None:
            raise ValueError("filename is null")
        fmt = logging.Formatter(fmt="%(lineno)d--->%(name)s--->%(levelname)s--->%(asctime)s--->%(message)s")
        file_handler = logging.FileHandler(filename, mode="a", encoding="utf-8")
        file_handler.setLevel(level)
        file_handler.setFormatter(fmt)
        return file_handler
